<{include file="wiget/header.tpl"}>
<{include file="wiget/navbar.tpl"}>
<link href="/static/bst/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="/static/timeselect/css/jquery-ui-1.9.1.custom.min.css" rel="stylesheet" type="text/css" />
<link href="/static/timeselect/css/jquery-ui-timepicker-addon.css" type="text/css" />

<script src="/static/jquery.min.js"></script>
<script src="/static/bst/js/bootstrap.min.js"></script>
<script src="/static/bst/bootstrap-validation.js"></script>

<script charset="utf-8" src="/static/kd/kindeditor.js"></script>
<script charset="utf-8" src="/static/kd/lang/zh_CN.js"></script>

<script type="text/javascript" src="/static/timeselect/js/jquery-ui.min.js"></script>
<script type="text/javascript" src="/static/timeselect/js/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript" src="/static/timeselect/js/jquery-ui-sliderAccess.js"></script>
<script type="text/javascript" src="/static/timeselect/js/datetime.custom.js"></script>
<script>
        var editor,editer_en;
        KindEditor.ready(function(K) {
                editor = K.create('#content',{items : ['bold', 'italic', 'underline', 'strikethrough', 'removeformat', '|', 'justifyleft', 'justifycenter', 'formatblock', 'insertorderedlist', 'insertunorderedlist', '|','subscript','superscript', 'about','clearhtml', 'code', '|','link', 'unlink', 'emoticons', 'shcode', 'image', 'table', 'quote', '|', 'source', 'fullscreen']});
                editor_en = K.create('#content_en',{items : ['bold', 'italic', 'underline', 'strikethrough', 'removeformat', '|', 'justifyleft', 'justifycenter', 'formatblock', 'insertorderedlist', 'insertunorderedlist', '|','subscript','superscript', 'about','clearhtml', 'code', '|','link', 'unlink', 'emoticons', 'shcode', 'image', 'table', 'quote', '|', 'source', 'fullscreen']});
        });
</script>
<div id='left'>
</div>
<form class="form-horizontal" id="form" accept-charset="utf-8" autocomplete="on" method="post" action="/edit/func/">
  <div class="control-group">
    <label class="control-label">大类别</label>
    <div class="controls">
      <select name="item_name" id="item_name" onchange="getContent()">
		<{if $pre_item}>
		<option value="<{$pre_item}>"><{$pre_item}></option>
		<{/if}>
		<option value="other">无分类</option>
		<{foreach $items as $item}>
		<option value="<{$item}>"><{$item}></option>
		<{/foreach}>
	  </select>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label">函数</label>
    <div class="controls">
      <input type="text" id="func_name" name="func_name" check-type="required charOrNum" required-message="函数不能为空！" maxlength="20"  onkeydown="getList()" onchange="getContent()" placeholder="函数" value="<{$pre_func}>"/>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label">一句话说明</label>
    <div class="controls">
      <input type="text" name="func_note" id="func_note" maxlength="30"  style="width:400px;" placeholder="函数的功能, 用途等等"/>
    </div>
  </div>
   <div class="control-group">
    <label class="control-label">中文内容</label>
    <div class="controls">
      <textarea type="textarea" rows="3" maxlength="10000" id="content" name="content" style="width:600px;height:250px;"></textarea>
    </div>
  </div>
  
  <div class="control-group">
    <label class="control-label">官方英文手册内容</label>
    <div class="controls">
      <textarea type="textarea" rows="3" maxlength="10000" id="content_en" name="content_en" style="width:600px;height:250px;"></textarea>
    </div>
  </div>
  <div class="control-group">
    <label class="control-label">预定发布时间</label>
    <div class="controls">
      <input type="text" class="datetime_timepicker" name="time" id="time" maxlength="30" placeholder="默认立刻发布" style="width:250px;" />
      
    </div>
  </div>
  <div class="control-group">
    <div class="controls">
	  <a href="<{$smarty.const.URL}>" class="btn btn-large">返回首页</a>
      <button type="submit" id="submit" name="op" value="func_edit" class="btn btn-large btn-primary">提交</button>
    </div>
  </div>
</form>
<script type="text/javascript">
//$('#form').validation();

$(function() {     
     var func = $('#func_name').val();
	 if('' == func) return false;
	 getContent();
}); 
function getList() {
	//TODO: 根据输入列表提示输入
	return true;
}

function getContent() {
	var func = $('#func_name').val();
	var item = $('#item_name').val();
	$.get('/js_data/func/',
		{'func':func,'item':item},function(data) {
			if( 0 == data) {
				$('#submit').html('确认新增函数');
				editor.html('<p>'+func+'函数功能：</p><p>'+func+'函数语法：</p><p>'+func+'函数说明：</p><p><br/></p><p>'+func+'函数例子：</p><p><ol><li></li></br><li></li></ol></p>');
				editor_en.html('');
				$('#func_note').val('');
				$('#time').val('');
				return false;
			}
			var obj = JSON.parse(data);
			editor.html(obj[0]['content']);
			editor_en.html(obj[0]['content_en']);
			$('#func_note').val(obj[0]['func_note']);
			$('#time').val(obj[0]['time']);
			$('#submit').html('确认修改');
		}
	);
}
function html_encode(str) {  //中文支持不好
  var s = "";  
  if (str.length == 0) return "";  
  s = str.replace(/&/g, "&gt;");  
  s = s.replace(/</g, "&lt;");  
  s = s.replace(/>/g, "&gt;");  
  s = s.replace(/ /g, "&nbsp;");  
  s = s.replace(/\'/g, "&#39;");  
  s = s.replace(/\"/g, "&quot;");  
  s = s.replace(/\n/g, "<br>");  
  return s;  
}  
function html_decode(str) {
  var s = "";
  if (str.length == 0) return "";
  s = str.replace(/&gt;/g,"&");
  s = s.replace(/&lt;/g,"<");
  s = s.replace(/&gt;/g,">");
  s = s.replace(/&nbsp;/g," ");
  s = s.replace(/&#39;/g,"\'");
  s = s.replace(/&quot;/g,"\"");
  s = s.replace(/<br>/g,"\n");
  return s;
}
</script>

<{include file="wiget/footer.tpl"}>